
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-23
 * @see :
 */

public abstract class UserGender {

    public final static int    $   = GroupRoot.$USER_GENDER$;
    public final static String _   = "USER_GENDER$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
                                                .lang(Language.$EN_US, "gender")
                                                .lang(Language.$ZH_CN, "性别")
                                                .done();
    
    public final static int    $UNKNOWN  = $ + 1;
    public final static String _UNKNOWN  = "USER_GENDER$UNKNOWN";
    @SystemData
    public final static Code   UNKNOWN   = CodeBuilder.code($, $UNKNOWN, _UNKNOWN)
                                                   .lang(Language.$EN_US, "unknown")
                                                   .lang(Language.$ZH_CN, "未知")
                                                   .done();
    public final static int    $MALE  = $ + 2;
    public final static String _MALE  = "USER_GENDER$MALE";
    @SystemData
    public final static Code   MALE   = CodeBuilder.code($, $MALE, _MALE)
                                                   .lang(Language.$EN_US, "male")
                                                   .lang(Language.$ZH_CN, "男")
                                                   .done();
    public final static int    $FEMALE  = $ + 3;
    public final static String _FEMALE  = "USER_GENDER$FEMALE";
    @SystemData
    public final static Code   FEMALE   = CodeBuilder.code($, $FEMALE, _FEMALE)
                                                   .lang(Language.$EN_US, "female")
                                                   .lang(Language.$ZH_CN, "女")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($UNKNOWN == id) return true;
        if($MALE == id) return true;
        if($FEMALE == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($UNKNOWN == id) return UNKNOWN;
        if($MALE == id) return MALE;
        if($FEMALE == id) return FEMALE;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_UNKNOWN.equals(key)) return UNKNOWN;
        if(_MALE.equals(key)) return MALE;
        if(_FEMALE.equals(key)) return FEMALE;
        return null;
    }
}
